<?php

namespace App\Http\Middleware;

use App\Repositories\DistributeRepository;
use Closure;
use Illuminate\Support\Facades\Auth;

class Distribute
{
    protected  $distributeRepository;
    public function __construct()
    {
       $this->distributeRepository=new DistributeRepository();
    }

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $firstLeader=$request->firstLeader;

        if($request->firstLeader){
            $user_id=Auth::user()->id;
            $this->distributeRepository->isHasLeader($user_id) ? '' : $this->distributeRepository;
        }
        return $next($request);
    }
}
